using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AchieveConfiguration : HOConfigurationReader
{
	public TextAsset table;

	protected Dictionary<int, AchieveInfo> mAchieveDictionary = new Dictionary<int, AchieveInfo>();

	public static AchieveConfiguration instance
	{
		get;
		private set;
	}

	public static Dictionary<int, AchieveInfo> achieveDictionary => instance.mAchieveDictionary;

	private void Awake()
	{
		if (instance == null)
		{
			instance = this;
			UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
			Read();
		}
		else
		{
			UnityEngine.Object.Destroy(this);
		}
	}

	public void OnApplicationQuit()
	{
		instance = null;
	}

	private void Read()
	{
		Hashtable hashtable = new Hashtable();
		ParseData(table, hashtable);
		IDictionaryEnumerator enumerator = hashtable.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.Current;
				AchieveInfo achieveInfo = new AchieveInfo();
				int num = 0;
				Hashtable hashtable2 = (Hashtable)dictionaryEntry.Value;
				achieveInfo.id = HOConfigurationReader.ParseTableValueToInt(hashtable2["ID"]);
				achieveInfo.name = HOConfigurationReader.ParseTableValueToString(hashtable2["Name"]);
				achieveInfo.type = (AchieveType)(1 << HOConfigurationReader.ParseTableValueToInt(hashtable2["Type"]));
				achieveInfo.level = HOConfigurationReader.ParseTableValueToString(hashtable2["Level"]);
				achieveInfo.goal = HOConfigurationReader.ParseTableValueToInt(hashtable2["Goal"]);
				achieveInfo.DescriptionID = HOConfigurationReader.ParseTableValueToInt(hashtable2["DescriptionID"]);
				achieveInfo.Description = HOConfigurationReader.ParseTableValueToString(hashtable2["Description"]);
				achieveInfo.IconName = HOConfigurationReader.ParseTableValueToString(hashtable2["IconName"]);
				achieveInfo.prizeChips = HOConfigurationReader.ParseTableValueToInt(hashtable2["PrizeChips"]);
				achieveInfo.prizeItemId = HOConfigurationReader.ParseTableValueToInt(hashtable2["PrizeItemId"]);
				achieveInfo.prizeItemCount = HOConfigurationReader.ParseTableValueToInt(hashtable2["PrizeItemCount"]);
				num = achieveInfo.id;
				mAchieveDictionary.Add(num, achieveInfo);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
	}
}
